package com.sky.controller.admin;

import com.sky.dto.OrdersCancelDTO;
import com.sky.dto.OrdersConfirmDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.dto.OrdersRejectionDTO;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.OrderService;
import com.sky.vo.OrderReportVO;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController("adminOrderController")
@RequestMapping("/admin/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    /**
     * 查询历史订单
     * @return
     */
    @GetMapping("/conditionSearch")
    public Result<PageResult> conditionSearch(OrdersPageQueryDTO dto){
        return orderService.conditionSearch(dto);
    }

    /**
     *各个订单数量查询
     * @return
     */
    @GetMapping("/statistics")
    public Result<OrderStatisticsVO> statistics(){
        return orderService.statistics();
    }

    /**
     * 查看详情
     * @param id
     * @return
     */
    @GetMapping("/details/{id}")
    public Result<OrderVO> details(@PathVariable Long id){
        return orderService.details(id);
    }

    /**
     * 接单
     * @param dto 接收订单id
     * @return
     */
    @PutMapping("/confirm")
    public Result confirm(@RequestBody OrdersConfirmDTO dto){
        return orderService.updateStatus(dto);
    }

    /**
     * 派单
     * @param id 订单id
     * @return
     */
    @PutMapping ("/delivery/{id}")
    public Result delivery(@PathVariable Long id){
        return orderService.delivery(id);
    }

    /**
     * 取消订单
     * @param dto
     * @return
     */
    @PutMapping ("/cancel")
    public Result cancelAdmin(@RequestBody OrdersCancelDTO dto){
        return orderService.cancel(dto);
    }

    /**
     * 拒绝订单
     * @param dto
     * @return
     */
    @PutMapping ("/rejection")
    public Result rejection(@RequestBody OrdersRejectionDTO dto){
        return orderService.rejection(dto);
    }

    /**
     * 完成订单
     * @param id 订单id
     * @return
     */
    @PutMapping ("/complete/{id}")
    public Result complete(@PathVariable Long id){
        return orderService.complete(id);
    }
}
